<%--
  Created by IntelliJ IDEA.
  User: 怪物大师
  Date: 2024/11/28
  Time: 18:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录页面</title>
    <script src="/js/jquery-3.7.1.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh; /* 使其填充整个视口 */
            margin: 0;
        }

        .login-container {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            width: 300px; /* 固定宽度 */
        }

        h2 {
            text-align: center;
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 5px;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%; /* 输入框填满宽度 */
            padding: 10px;
            margin-bottom: 15px; /* 输入框之间的间距 */
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box; /* 使边框和内边距包容 */
        }

        .button-container {
            display: flex; /* 使用Flexbox布局 */
            justify-content: space-between; /* 使按钮分开 */
        }

        button {
            padding: 10px;
            color: white; /* 字体颜色 */
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background 0.3s;
            flex: 1; /* 按钮平分宽度 */
        }

        button.login {
            background-color: #4CAF50; /* 登录按钮背景颜色 */
        }

        button.login:hover {
            background-color: #45a049; /* 鼠标悬停时变颜色 */
        }

        button.register {
            background-color: #007BFF; /* 注册按钮背景颜色 */
            margin-left: 10px; /* 注册按钮左侧间距 */
        }

        button.register:hover {
            background-color: #0056b3; /* 鼠标悬停时变颜色 */
        }

        .error-message {
            color: red; /* 错误消息的颜色 */
            text-align: center;
            margin-top: 10px;
        }
    </style>
</head>
<body>

<div class="login-container">
    <h2>登录</h2>
    <form id="loginForm" action="/user/login" method="post">
        <label for="username">用户名:</label>
        <input type="text" id="username" name="username" required>
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required>
        <div class="button-container">
            <button class="login" id="login" type="submit">登录</button>
            <button class="register" id="register" type="button">注册</button>
        </div>
        <div class="error-message" id="errorMessage">${msg}</div>
    </form>
</div>

<script src="/js/jquery-3.7.1.min.js"></script>
<script>

    document.getElementById("register").onclick = function() {
        // 修改表单的action属性为注册
        document.getElementById("loginForm").action = "/user/register";
        // 提交表单
        document.getElementById("loginForm").submit();

    };
</script>

</body>
</html>
